package com.yueka.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yueka.pojo.entity.student.Student;
import com.yueka.pojo.entity.student.StudentQueryParam;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface StudentMapper extends BaseMapper<Student> {
    Page<Student> getStudentList(@Param("page") Page<Student> page, @Param("param") StudentQueryParam studentQueryParam);

    void insertStudent(Student student);

    void updateStudent(Student student);

    List<Student> getInIds(Integer[] ids);

    @Select("SELECT id, student_name, gender, age, phone, source, status, enroll_date, remark, birthday_type, birthday, create_time, update_time FROM student WHERE phone = #{phone}")
    Student login(Student student);

    void register(Student student);

    @Insert("INSERT INTO student(student_name, phone, age, source, status, create_time, update_time) VALUES(#{studentName}, #{phone}, #{age}, #{source}, #{status}, #{createTime}, #{updateTime})")
    void webInsertStudent(Student student);

    @Select("SELECT id, student_name, gender, age, phone, source, status, enroll_date, remark, birthday_type, birthday, create_time, update_time FROM student WHERE phone = #{phone} and student_name = #{studentName} and status > '2'")
    Student selectByPhone(String phone, String studentName);
}
